﻿using UnityEngine;
using System.Collections;
public class TestCamera : MonoBehaviour
{
    public string deviceName;
    public Renderer mySpriteRender;
    WebCamTexture tex;
    IEnumerator Start()
    {
        //获取授权  
        yield return Application.RequestUserAuthorization(UserAuthorization.WebCam);
        if (Application.HasUserAuthorization(UserAuthorization.WebCam))
        {
            WebCamDevice[] devices = WebCamTexture.devices;
            deviceName = devices[0].name;
            tex = new WebCamTexture(deviceName, 360, 360, 12);
            mySpriteRender.material.mainTexture = tex;
            tex.Play();
        }
        else
        {
        }
    }
}